/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const {DefinePlugin} = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
  entry: './src/js/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, './dist'),
  },
  mode: 'development',
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: ['babel-loader', 'eslint-loader'],
      },
      {
        test:/\.css$/,
        use:[{
            loader:'style-loader'
        },{
            loader:'css-loader'
        },{
            loader:'postcss-loader'
        }]
    },
    {
        test:/\.less$/,
        use: [
          "style-loader",
          {
            loader: "css-loader",
            options: {
              importLoaders: 2
            }
          },
          "postcss-loader",
          "less-loader"
        ]
    },
    {
      test: /\.vue$/,
      exclude: /node_modules/,
      use: ['vue-loader'],
    },
    ],
  },
  plugins:[
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
        template:'./src/index.html'
    }),
    new DefinePlugin({
        BASE_URL:'"./"'
    }),
    new CopyWebpackPlugin({
        patterns:[{
            from:'public',
            globOptions:{
            ignore:[
                '**/.DS_Store',
                '**/index.html'
            ]
           }
        }]
    }),
    new VueLoaderPlugin()
]
};
